import { Modal } from "antd"
import { useImperativeHandle, useState, forwardRef, Ref, ForwardedRef } from "react"

export interface InfoRef {
    showModal():void
}

const InfoModal = (props:{},ref:ForwardedRef<InfoRef>) => {

    const [modalVisible, setModalVisible] = useState(false)

    const showModal = () => {
        setModalVisible(true)
    }

    useImperativeHandle(
        ref,
        () => ({
          showModal() {
            showModal()
          }
        }),
        []
      );

    const handleOk = () => {
        setModalVisible(false)
    }

    const handleCancel = () => {
        setModalVisible(false)
    }

    return (
        <Modal
            title="个人信息"
            open={modalVisible}
            onOk={handleOk}
            onCancel={handleCancel}
            destroyOnClose={true}
        >
            <p>个人信息：不过暂时没有咯</p>
            <p>你们就随便看看就行了</p>
            <p>好了别看了，知道我长得帅了</p>
        </Modal>
    )
}

export default forwardRef(InfoModal)